import request from '@/utils/request'

// 获取员工列表
export const getEmployeeListAPI = (params) => request.get('/sys/user', { params })

// 封装导出员工excel的API
export const exportEmployeeAPI = () => request.get('/sys/user/export', { responseType: 'blob' })

// 封装下载模块的API
export const exportTemplateAPI = () => request.get('/sys/user/import/template', { responseType: 'blob' })

// 封装上传excel的API
export const uploadExcelAPI = (data) => request.post('/sys/user/import', data, {
  headers: {
    // 正常请求的是json application/json格式
    'Content-Type': 'multipart/form-data'
  }
})

// 封装删除员工的API
export const delEmployeeAPI = (id) => request.delete(`sys/user/${id}`)

// 新增员工
export const addEmployeeAPI = (data) => request.post('/sys/user', data)

// 获取详情
export const getEmployeeDetailAPI = (id) => request.get(`/sys/user/${id}`)

// 封装更新员工的API
export function updateEmployeeAPI(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}

// 给员工分配角色
export const assignRoleAPI = (data) => request.put('/sys/user/assignRoles', data)
